package link.ahsj.sqlserver.conctroller;

import link.ahsj.sqlserver.entity.Demo;
import link.ahsj.sqlserver.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author Eastern unbeaten
 * @version 1.0
 * @date 2019/6/11 7:16
 * @mail chenshiyun2011@163.com
 */
@RestController
@RequestMapping("/")
public class OpenApi {

    @Autowired
    private DemoService demoService;

    @GetMapping("/list")
    public ResponseEntity<Object> login() {
        return ResponseEntity.ok(demoService.list());
    }

    @GetMapping("/list2")
    public ResponseEntity<Object> list2() {
        return ResponseEntity.ok(demoService.getLists());
    }

    @GetMapping("/add")
    public ResponseEntity<Object> add() {
        Demo d = new Demo();
        d.setId(UUID.randomUUID().toString());
        d.setName("name");
        d.setNickName("nickName");
        d.setPassword("password");
        demoService.save(d);
        return ResponseEntity.ok(d);
    }

}
